ifeq ($(KERNELRELEASE), )
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
#default:
#	$(MAKE) -C $(KERNELDIR)  M=$(PWD)  
#clean:
#	rm -rf .tmp_versions Module.symvers *.mod.c *.o *.ko .*.cmd Module.markers modules.order
#load:
#	insmod ch34x.ko
#unload:
#	rmmod ch34x
install: 
	# unload
	-rmmod ch341
	-rm -rf /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/ch341.ko
	-rmmod ch34x
	-rm -rf /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/ch34x.ko
	depmod

	# clean
	-rm -rf .tmp_versions Module.symvers *.mod.c *.o *.ko .*.cmd Module.markers modules.order

	# bliuding
	$(MAKE) -C $(KERNELDIR)  M=$(PWD)

	# install
	mkdir -p /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/
	cp -f ./ch34x.ko /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/
	depmod
	
	# load
	modprobe usbserial
	insmod /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/ch34x.ko
uninstall:
	rmmod ch34x
	rm -rf /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/ch34x.ko
	depmod
else
	obj-m := ch34x.o
endif
